// 专门处理role角色管理
import axios from '@/api/common.js'

export const getAllRoleList = () => {
  return axios({
    url: 'roles'
  })
}
// 删除角色指定权限
export const delRightById = (roleId, rightId) => {
  return axios({
    method: 'delete',
    url: `roles/${roleId}/rights/${rightId}`
  })
}
// 角色授权
export const grantRightByRole = (roleId, rids) => {
  return axios({
    method: 'post',
    url: `roles/${roleId}/rights`,
    data: { rids }
  })
}
// 添加角色
export const addRole = (roleName, roleDesc) => {
  return axios({
    method: 'post',
    url: 'roles',
    data: { roleName, roleDesc }
  })
}
// 删除角色
export const delRoleById = (id) => {
  return axios({
    method: 'delete',
    url: `roles/${id}`
  })
}
// 获取角色信息
export const getRoleById = (id) => {
  return axios({
    url: `roles/${id}`
  })
}
// 编辑角色信息
export const editRoleById = (data) => {
  return axios({
    method: 'put',
    url: `roles/${data.id}`,
    data: { roleName: data.roleName, roleDesc: data.roleDesc }
  })
}
